﻿
<h3>菜品销售单</h3>
<script src="~/js/vue.min.js"></script>
<script src="~/js/axios.min.js"></script>
<script src="~/js/qs.min.js"></script>
@using Model
@model List<DishSalesInfo>
*

<style type="text/css">
    tr.change:hover {
        background-color: #00FF00
    }
</style>
<div id="vue-menu">

    <table id="tm" class="table table-bordered" style="width:800px;margin: auto;text-align: center;">
        <tr class="change" style="background-color:cadetblue">
            <td>点菜时间</td>
            <td>餐桌号</td>
            <td>菜品</td>
            <td>菜品数量</td>
            <td>价钱</td>
            <td>操作</td>
        </tr>
        <tr v-for="item in dishSalesInfo" >
            <td>{{item._DishEndTime | formatTime('yyyy年MM月dd日')}}</td>
            <td>{{item._Zid}}</td>
            <td>{{item._DishiId}}</td>
            <td>{{item.amount}}</td>
            <td>{{item.dishPay}}<span>元</span></td>
            <td><input type="button" v-on:click="" value="详情" /></td>
        </tr>
    </table>
</div>
<script>
    new Vue({
        el:"#vue-menu",
        data: {
            dishSalesInfo:[],

        },
        mounted: function () {
            axios
                .get("/Dishs/GetSalesInfos")
                .then(res => (this.dishSalesInfo = res.data))
                .catch(function (error) {
                    console.log(error)
                });
        },
        //时间转换
        filters: {
            formatTime: function (date, fmt) {
                var date = new Date(date);
                if (/(y+)/.test(fmt)) { 
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                var o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (var k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) {
                        var str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
                    }
                }
                return fmt;
            },
            formatTime1: function (date, fmt) {
                var date = new Date(date);
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                var o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (var k in o) {
                    if (new RegExp('(' + k + ')').test(fmt)) {
                        var str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
                    }
                }
                return fmt;
            }
        }
    })
</script>